home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / ALARM / ALARM.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-10-28  |  3.1 KB  |  96 lines

  1. VERSION 5.00
  2. Begin VB.Form AlarmForm 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Alarm Clock"
  5.    ClientHeight    =   780
  6.    ClientLeft      =   5010
  7.    ClientTop       =   4245
  8.    ClientWidth     =   3135
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Icon            =   "ALARM.frx":0000
  19.    LinkTopic       =   "Form2"
  20.    MaxButton       =   0   'False
  21.    PaletteMode     =   1  'UseZOrder
  22.    ScaleHeight     =   780
  23.    ScaleWidth      =   3135
  24.    StartUpPosition =   2  'CenterScreen
  25.    Begin VB.Timer Timer1 
  26.       Interval        =   500
  27.       Left            =   2640
  28.       Top             =   120
  29.    End
  30.    Begin VB.Label lblTime 
  31.       BeginProperty Font 
  32.          Name            =   "MS Sans Serif"
  33.          Size            =   12
  34.          Charset         =   0
  35.          Weight          =   700
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   495
  41.       Left            =   120
  42.       TabIndex        =   0
  43.       Top             =   120
  44.       Width           =   2415
  45.    End
  46. Attribute VB_Name = "AlarmForm"
  47. Attribute VB_GlobalNameSpace = False
  48. Attribute VB_Creatable = False
  49. Attribute VB_PredeclaredId = True
  50. Attribute VB_Exposed = False
  51. Option Explicit
  52. Dim AlarmTime
  53. Const conMinimized = 1
  54. Private Sub Form_Click()
  55.     AlarmTime = InputBox("Enter alarm time", "VB Alarm", AlarmTime)
  56.     If AlarmTime = "" Then Exit Sub
  57.     If Not IsDate(AlarmTime) Then
  58.         MsgBox "The time you entered was not valid."
  59.     Else                                    ' String returned from InputBox is a valid time,
  60.         AlarmTime = CDate(AlarmTime)        ' so store it as a date/time value in AlarmTime.
  61.     End If
  62. End Sub
  63. Private Sub Form_Load()
  64.     AlarmTime = ""
  65. End Sub
  66. Private Sub Form_Resize()
  67.     If WindowState = conMinimized Then      ' If form is minimized, display the time in a caption.
  68.         SetCaptionTime
  69.     Else
  70.         Caption = "Alarm Clock"
  71.     End If
  72. End Sub
  73. Private Sub SetCaptionTime()
  74.     Caption = Format(Time, "Medium Time")   ' Display time using medium time format.
  75. End Sub
  76. Private Sub Timer1_Timer()
  77. Static AlarmSounded As Integer
  78.     If lblTime.Caption <> CStr(Time) Then
  79.         ' It's now a different second than the one displayed.
  80.         If Time >= AlarmTime And Not AlarmSounded Then
  81.             Beep
  82.             MsgBox "Alarm at " & Time
  83.             AlarmSounded = True
  84.         ElseIf Time < AlarmTime Then
  85.             AlarmSounded = False
  86.         End If
  87.         If WindowState = conMinimized Then
  88.             ' If minimized, then update the form's Caption every minute.
  89.             If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
  90.         Else
  91.             ' Otherwise, update the label Caption in the form every second.
  92.             lblTime.Caption = Time
  93.         End If
  94.     End If
  95. End Sub
  96.